<%@page import="com.shop.pandian.app.model.*" %>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ include file="/commons/taglibs.jsp" %>

<title><fmt:message key="Product.title"/></title>
<script type="text/javascript" >

$(".product").addClass("active").closest("ul").show().siblings("a").addClass("active");
	$(document).ready(function() {
		// 分页需要依赖的初始化动作
		addDatePicker('.form_date');
		addDateTimePicker('.form_datetime'); 
		addPaginator('#pagination', '${page.thisPageNumber}','${page.lastPageNumber}');
		

	});
</script>



<form:form action="${ctx}/product/list" modelAttribute="query" id="queryForm" name="queryForm" method="get" style="display: inline;">

	<fieldset> 
		<legend>搜索</legend>
		<div class="form-group">			

			<div class="row offset4"> 				

				<div class="col-md-2 col-xs-4"><label><fmt:message key="Product.productName.title"/> </label> </div>
				
				<div class="col-md-3 col-xs-8"> 
					<form:input path="productName" id="productName" cssClass="form-control" maxlength="100" class=""/> 
				</div>


				<div class="col-md-2 col-xs-4"><label><fmt:message key="Product.productDesc.title"/> </label> </div>
				
				<div class="col-md-3 col-xs-8"> 
					<form:input path="productDesc" id="productDesc" cssClass="form-control" maxlength="255" class=""/> 
				</div>



			</div>
			<div class="row offset4"> 				

				<div class="col-md-2 col-xs-4"><label><fmt:message key="Product.price.title"/> </label> </div>
				
				<div class="col-md-3 col-xs-8"> 
					<form:input path="price" id="price" cssClass="form-control" maxlength="10" class=""/> 
				</div>


				<div class="col-md-2 col-xs-4"><label><fmt:message key="Product.productCategoryId.title"/> </label> </div>
				
				<div class="col-md-3 col-xs-8">  
				    <form:select path="productCategoryId" cssClass="form-control" id="productCategoryId">
				    	<form:option value=""><fmt:message key="selection.label.pleaseselectone"/></form:option>
				    	<form:options items="${productCategoryList}" itemLabel="categoryName" itemValue="id" />
				    </form:select>
				   </div>



			</div>

		</div>
	</fieldset>
	<div class="handleControl"> 
		<input type="submit" class="btn btn-primary" style="width:80px" value="<fmt:message key="navigation.button.query"/>" onclick="getReferenceForm(this).action='${ctx}/product/list'"/>
		<input type="submit" class="btn btn-success" style="width:80px" value="<fmt:message key="navigation.button.new"/>" onclick="getReferenceForm(this).action='${ctx}/product/create.do'"/>
		<input type="button" class="btn btn-danger" style="width:80px" value="<fmt:message key="navigation.button.delete"/>" onclick="batchDelete('${ctx}/product/delete','items',document.forms.queryForm)"/>
	</div>


	<div class="panel-body">	
		<c:if test="${page.lastPageNumber > 1}">
		<div class=" pull-right">
		<ul id="pagination"></ul>
		</div>
		</c:if>
		
		<input type="hidden" name="sortColumns" value="${query.sortColumns}" />
		<input type="hidden" name="pageNumber" value="${query.pageNumber}" />
		
		<div class="table-responsive">			
			<table class="table table-bordered table-striped table-condensed table-collapsible">
			  <thead>
				  
				  <tr>
					<th style="width:1px;"> </th>
					<th style="width:1px;"><input type="checkbox" onclick="setAllCheckboxState('items',this.checked)"></th>
					
					<th><fmt:message key="Product.productName.title"/> </th>
					<th><fmt:message key="Product.productDesc.title"/> </th>
					<th><fmt:message key="Product.price.title"/> </th>
					<th><fmt:message key="Product.productCategoryId.title"/> </th>
		
					<th><fmt:message key="navigation.label.operation"/></th>
				  </tr>
				  
			  </thead>
			  <tbody>
			  	  <c:forEach items="${page.result}" var="item" varStatus="status">
			  	  
				  <tr>
					<td data-label="序号">${page.thisPageFirstElementNumber + status.index}</td>
					<td><input type="checkbox" name="items" value="id=${item.id}&"></td>
					
					<td data-label="<fmt:message key="Product.productName.title"/>"><c:out value='${item.productName}'/>&nbsp;</td>
					<td data-label="<fmt:message key="Product.productDesc.title"/>"><c:out value='${item.productDesc}'/>&nbsp;</td>
					<td data-label="<fmt:message key="Product.price.title"/>"><c:out value='${item.price}'/>&nbsp;</td>
					<td data-label="<fmt:message key="Product.productCategoryId.title"/>"><c:out value='${item.productCategory.categoryName}'/>&nbsp;</td>
					<td data-label="<fmt:message key="navigation.label.operation"/>">
						<a href="${ctx}/product/show?id=${item.id}&" class="btn btn-info"><fmt:message key="navigation.button.view"/></a>&nbsp;&nbsp;&nbsp;
						<a href="${ctx}/product/edit?id=${item.id}&" class="btn btn-warning"><fmt:message key="navigation.button.edit"/></a>
					</td>
				  </tr>
				  
			  	  </c:forEach>
			  </tbody>
			</table>
		</div>
	</div>
</form:form>



